OCAMLC = ocamlc
OCAMLLEX = ocamllex
OCAMLYACC = ocamlyacc 

OBJS = ast.cmo latticeCreation.cmo latparser.cmo scanner.cmo printLattice.cmo semanticAnalysis.cmo clone.cmo evaluate.cmo latte.cmo 
OBJS2 = ast.cmo latticeCreation.cmo latparser.cmo scanner.cmo printLattice.cmo semanticAnalysis.cmo clone.cmo evaluate.cmo latte.cmo 

all: latte

scanner.ml: scanner.mll
	$(OCAMLLEX) scanner.mll

latparser.ml: latparser.mly
	$(OCAMLYACC) latparser.mly

ast.cmo: ast.ml
	$(OCAMLC) -c ast.ml

latticeCreation.cmo: latticeCreation.ml ast.cmo
	$(OCAMLC) -c latticeCreation.ml

latparser.cmi: latparser.ml ast.cmo latticeCreation.cmo
	$(OCAMLC) -c latparser.mli

latparser.cmo: latparser.ml ast.cmo latparser.cmi latticeCreation.cmo
	$(OCAMLC) -c latparser.ml

scanner.cmo: scanner.ml latparser.cmi
	$(OCAMLC) -c scanner.ml

printLattice.cmo: printLattice.ml ast.cmo latparser.cmi latticeCreation.cmo
	$(OCAMLC) -c printLattice.ml

semanticAnalysis.cmo: latticeCreation.ml printLattice.cmo
	$(OCAMLC) -c semanticAnalysis.ml

clone.cmo: clone.ml
	$(OCAMLC) -c clone.ml

evaluate.cmo: evaluate.ml ast.cmo latparser.cmo scanner.cmo printLattice.cmo clone.cmo
	$(OCAMLC) -c evaluate.ml

latte.cmo: latte.ml latticeCreation.cmo semanticAnalysis.cmo evaluate.cmo ast.cmo latparser.cmo scanner.cmo printLattice.cmo
	$(OCAMLC) -c latte.ml

latte: $(OBJS)
	$(OCAMLC) -o latte -g $(OBJS)

clean:
	rm -f $(OBJS) test ast.cmo test.cmi parser.cmi scanner.cmi parser.mli parser.ml scanner.ml *.cmi *.cmo *.log latte
	rm -f ./../test-cases/*.diff ./../test-cases/*.out ./../test-cases/*.log *.rtf

test: latte
	./RunTests.sh 

toRTF: clean
	enscript *.ml --language=rtf  -Eocaml --color -o LattakiaSource.rtf
